Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

signal-exit

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signal-exit

when you want to fire an event no matter how a process exits.

  • 3.0.7
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is signal-exit?

The signal-exit package is used to capture and handle events that indicate Node.js process is about to exit. This includes handling of signals like SIGINT and SIGTERM, as well as normal process termination. It allows developers to register callbacks that can perform cleanup or other final actions before the process exits.

What are signal-exit's main functionalities?

Capture exit events

This feature allows you to capture any kind of exit, whether it's due to a signal or a normal exit. The callback function is called with the exit code and the signal that caused the exit, if applicable.

const onExit = require('signal-exit');

const removeExitHandler = onExit(function (code, signal) {
  console.log('Process is exiting with code:', code, 'and signal:', signal);
});

// Later, if you decide you do not want to handle the exit:
removeExitHandler();

Unregister exit handler

This feature allows you to unregister a previously registered exit handler. This is useful if the exit handling logic is no longer needed, or if you want to replace it with a different handler.

const onExit = require('signal-exit');

const removeExitHandler = onExit(function () {
  // cleanup logic here
});

// When you no longer need to handle exits:
removeExitHandler();

Other packages similar to signal-exit

Keywords

FAQs

Package last updated on 03 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc